// RWCriticalSection.h: interface for the CRWCriticalSection class.
//
//////////////////////////////////////////////////////////////////////
// (c) Jerome Sopocko 2003
// this code worked last time I saw it
//////////////////////////////////////////////////////////////////////
// v1.0 27/10/2003	First release
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_RWCRITICALSECTION_H__A0994F02_8CE5_45CB_975C_C0D1D5F93BF8__INCLUDED_)
#define AFX_RWCRITICALSECTION_H__A0994F02_8CE5_45CB_975C_C0D1D5F93BF8__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class CRWCriticalSection  
{
public:
	CRWCriticalSection();
	virtual ~CRWCriticalSection();
protected:
	HANDLE m_hNobodyIsReading;
	HANDLE m_hWritingMutex;
	CRITICAL_SECTION m_csReading;
	int m_nReaders;
public:
	bool LockReader(DWORD dwTimeOut=INFINITE);
	void UnlockReader();
	bool LockWriter(DWORD dwTimeOut=INFINITE);
	void UnlockWriter();

};

#endif // !defined(AFX_RWCRITICALSECTION_H__A0994F02_8CE5_45CB_975C_C0D1D5F93BF8__INCLUDED_)
